/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package vip.xiaonuo.biz.modular.wall_image.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.mybatisflex.core.paginate.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.UploadedFile;
import org.noear.solon.validation.annotation.NotEmpty;
import org.noear.solon.validation.annotation.Valid;
import org.noear.solon.validation.annotation.Validated;
import vip.xiaonuo.biz.modular.wall_image.entity.BizWallImage;
import vip.xiaonuo.biz.modular.wall_image.param.BizWallImageAddParam;
import vip.xiaonuo.biz.modular.wall_image.param.BizWallImageEditParam;
import vip.xiaonuo.biz.modular.wall_image.param.BizWallImageIdParam;
import vip.xiaonuo.biz.modular.wall_image.param.BizWallImagePageParam;
import vip.xiaonuo.biz.modular.wall_image.service.BizWallImageService;
import vip.xiaonuo.biz.modular.wall_image.wrapper.BizWallImageWrapper;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.annotation.CommonWrapper;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * 壁纸信息控制器
 *
 * @author KingTiger
 * @date 2025/05/27 15:44
 */
@Api(tags = "壁纸信息控制器")
@Controller
@Valid
public class BizWallImageController {

    @Inject
    private BizWallImageService bizWallImageService;

    /**
     * 获取壁纸信息分页
     *
     * @author KingTiger
     * @date 2025/05/27 15:44
     */
    @ApiOperation("获取壁纸信息分页")
    @SaCheckPermission("/biz/wall_image/page")
    @Get
    @Mapping("/biz/wall_image/page")
    @CommonWrapper(value = BizWallImageWrapper.class)
    public CommonResult<Page<BizWallImage>> page(BizWallImagePageParam bizWallImagePageParam) {
        return CommonResult.data(bizWallImageService.page(bizWallImagePageParam));
    }

    /**
     * 添加壁纸信息
     *
     * @author KingTiger
     * @date 2025/05/27 15:44
     */
    @ApiOperation("添加壁纸信息")
    @CommonLog("添加壁纸信息")
    @SaCheckPermission("/biz/wall_image/add")
    @Post
    @Mapping("/biz/wall_image/add")
    public CommonResult<String> add(@Body @Validated BizWallImageAddParam bizWallImageAddParam) {
        bizWallImageService.add(bizWallImageAddParam);
        return CommonResult.ok();
    }

    /**
     * 添加壁纸信息(批量)
     *
     * @author KingTiger
     * @date 2025/05/27 15:44
     */
    @ApiOperation("添加壁纸信息(批量)")
    @CommonLog("添加壁纸信息(批量)")
    @SaCheckPermission("/biz/wall_image/addBatch")
    @Post
    @Mapping("/biz/wall_image/addBatch")
    public CommonResult<String> addBatch(
            @Param("categoryId") String categoryId,
            @Param("file") UploadedFile file
    ) {
        bizWallImageService.addBatch(categoryId, file);
        return CommonResult.ok();
    }

    /**
     * 编辑壁纸信息
     *
     * @author KingTiger
     * @date 2025/05/27 15:44
     */
    @ApiOperation("编辑壁纸信息")
    @CommonLog("编辑壁纸信息")
    @SaCheckPermission("/biz/wall_image/edit")
    @Post
    @Mapping("/biz/wall_image/edit")
    public CommonResult<String> edit(@Body @Validated BizWallImageEditParam bizWallImageEditParam) {
        bizWallImageService.edit(bizWallImageEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除壁纸信息
     *
     * @author KingTiger
     * @date 2025/05/27 15:44
     */
    @ApiOperation("删除壁纸信息")
    @CommonLog("删除壁纸信息")
    @SaCheckPermission("/biz/wall_image/delete")
    @Post
    @Mapping("/biz/wall_image/delete")
    public CommonResult<String> delete(@Body @Validated @NotEmpty(message = "集合不能为空")
                                       List<BizWallImageIdParam> bizWallImageIdParamList) {
        bizWallImageService.delete(bizWallImageIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取壁纸信息详情
     *
     * @author KingTiger
     * @date 2025/05/27 15:44
     */
    @ApiOperation("获取壁纸信息详情")
    @SaCheckPermission("/biz/wall_image/detail")
    @Get
    @Mapping("/biz/wall_image/detail")
    @CommonWrapper(value = BizWallImageWrapper.class)
    public CommonResult<BizWallImage> detail(@Validated BizWallImageIdParam bizWallImageIdParam) {
        return CommonResult.data(bizWallImageService.detail(bizWallImageIdParam));
    }
}
